package cn.dnui_lf_705.dnui_16110100705.controller;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;

import cn.dnui_lf_705.dnui_16110100705.R;


public abstract class BaseActivity extends AppCompatActivity {
        protected int layout_file= R.layout.activity_main;   //为什么是activity_main
        abstract void initViews();
        abstract void initEvents();
        abstract void initData();

        void setLayout(int layout_file)
        {
            setContentView(layout_file);
        }
    @Override
    protected void onCreate(Bundle savedInstanceState) {        //不是抽象方法吗为什么会有函数并且还要onCreate
        super.onCreate(savedInstanceState);
        setLayout(layout_file);
      //  initViews();
      //  initEvents();
       // initData();
    }
    public String getUser_id(){
        SharedPreferences sp;
        sp = getSharedPreferences("userInfo", Context.MODE_PRIVATE);
        return sp.getString("user_id","");
    }
    public String getUser_password()
    {
        SharedPreferences sp;
        sp = getSharedPreferences("userInfo",Context.MODE_PRIVATE);
        return sp.getString("userpass","");
    }
    public void showToast(String content)
    {
        Toast.makeText(this,content,Toast.LENGTH_LONG).show();
    }
}
